<%--
 *  File:    FleeGoodsDataAccumulatedSummary.jsp
 *  @Author: GenGan
 *  Date:    2012/03/20
 *
 *  Copyright (C) 2000 - 2012 Oval Technologies, Inc.
 *  All rights reserved. 
 *
 *  This software is the confidential and proprietary information of Oval 
 *  Technologies, Inc. ("Confidential Information").  You shall not
 *  disclose such Confidential Information and shall use it only in
 *  accordance with the terms of the license agreement you entered into
 *  with Oval.
--%>


<%@ include file="/inc/SessionTimeout.inc"%>
<%@ page language="java"%>
<%@ page import="java.util.*"%>
<%@ page import="org.apache.log4j.Category"%>
<%@ page import="com.oval.util.*"%>

<%@ page contentType="text/html;charset=UTF-8"%>
<%@ taglib uri="/WEB-INF/PageFlow.tld" prefix="PageFlow"%>
<%@ taglib uri="/WEB-INF/struts-logic.tld" prefix="logic"%>
<%@ taglib uri="/WEB-INF/oval-tag.tld" prefix="oval"%>
<%@ taglib uri="/WEB-INF/custom.tld" prefix="custom"%>

<%
  Category cat = Category.getInstance("jsp.FleeGoodsDataAccumulatedSummary");  
  String strTableName = "v_zylchuanhuoinfosummary";
  String strModuleName = "DMS";
  String privilegeCode = "A0604";
  String contextPath = request.getContextPath();
%>



<%@ include file="/inc/Security.inc"%>
<%@ include file="/inc/FrmDefault.inc"%>
<%@ include file="/inc/PageDefault.inc"%>
<%@ include file="/inc/LocationDefault.inc"%>
<%@ include file="/inc/NewCalendar.inc"%>
<%@ include file="/inc/AlertError.inc"%>
<%int LangNums = ConstantProp.multiLangNumber;%>
<html>
<iframe name="summaryfrm" scrolling="no" frameborder="0"
	style="position:absolute; top:0px; left:0px; display:none;border:#909eff 1px solid;"></iframe>
<head>
<title>FleeGoodsDataAccumulatedSummary</title>
<PageFlow:CheckPageFlow pageName="p_getchuanhuoinfosummary" />
<%@ include file="/inc/SumDiv.inc"%>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<link rel="stylesheet"
	href="<%=contextPath %>/css/<%= strLanguageCode %>/main.css"
	type="text/css">
<script language="JavaScript"
	src="<%=contextPath %>/css/<%= strLanguageCode %>/script.js"></script>
<script language="JavaScript" src="<%=contextPath %>/js/FuncLib.js"></script>
<script language="JavaScript" src="<%=contextPath %>/js/ScriptLib.js"></script>
<script language="JavaScript" src="<%=contextPath%>/js/mnemoniccode.js"></script>
<script language="JavaScript"
	src="<%=contextPath%>/js/SummaryDivision.js"></script>
<script language="JavaScript" src="<%=contextPath %>/js/NewCalendar.js"></script>

<script language="JavaScript">
// order column
function page_summary(actionvalue,orderbyname)
{
  var editform = summaryPrepare(document.cform, actionvalue, orderbyname);
  if (editform == false)
      return;
  editform.action = "FleeGoodsDataAccumulatedSummary.jsp?<%= OvalTools.randomURL() %>";
  editform.target = "_self";
  isRunning = true;
  editform.submit();
}

//add data record
function page_add()
{
  var updloadvalue = document.cform.startdate.value;
  var enddate = document.cform.enddate.value;
  var flag=document.cform.flag.value;
  var productid=document.cform.productid.value;
  //if(!checkForm(cform)) return;
  var qty = document.cform.qty;
  if(flag=="" || flag==null){
		alert("类型不能为空");
		flag.focus();
		return;
  }
 if(productid=="" || productid==null){
		alert("产品的值不能为空");
		prodcode.focus();
		return;
 }
  if(qty.value=="" || qty.value==null){
		alert("数量不能为空");
		qty.focus();
		return;
 }
  if (isNaN(Number(qty.value))){
		alert("请输入正确的数值！");
		qty.focus();
		return;
  }  
  if(!isDate(updloadvalue,"yyyy-MM-dd")){
		alert("日期格式不正确！");
		updloadvalue.focus();
		return;
	  }
  if(!isDate(enddate,"yyyy-MM-dd")){
		alert("日期格式不正确！");
		enddate.focus();
		return;
	  }
  if(updloadvalue=="" || updloadvalue==null){
		alert("开始时间不能为空");
		updloadvalue.focus();
		return;
	  }
  cform.actionname.value = "add";
  cform.target = "_self";
  isRunning = true;
  cform.submit();
}

// delete data record
function page_delete()
{
  if(isNullChecked(cform.zylchuanhuoinfoids)) 
  {
    alert('<%=message.getMessageDesc("PLEASE_SELECT")%>');
    return;
  }
  var flag = confirm("<%= message.getMessageDesc("ARE_YOU_SURE_DEL") %>");
  if(!flag)
    return;
  cform.actionname.value = "del";
  cform.target = "_self";
  isRunning = true;
  cform.submit();
}
function page_save()
{
 if(!checkForm(cform)) return;
 if(!checkALLElems(document.getElementById("olddetail"))) return;
 if(!checkalltext())return;
   //checkalltext();
  cform.actionname.value = "save";
  cform.target = "_self";
  isRunning = true;
  cform.submit();
}

//check all checkbox
function page_checkall(){
	var allcheck = cform.checkall;
	var allfile = document.getElementsByName("zylchuanhuoinfoids");
	for(var i = 0 ; i < allfile.length;i++){
		allfile[i].checked = allcheck.checked;
	}
}
function page_checkNum(obj) 
{
		if(obj.value=="")
			return;
		if (isNaN(Number(obj.value))){
			alert("请输入正确的数值！");
			obj.focus();
		}
}	


function page_setProduct(id,code,name,price,spec){	
		cform.productid.value=id;
		cform.prodcode.value=code;
		cform.prodname.value=name;
		hiddenFrm();
}

var isHidden;
function frm_select(e){
	isHidden = "block";
	var _target = getPosition(e);
    var _obj = document.getElementById("summaryfrm");
    _obj.style.left = _target.x;
    _obj.style.top = _target.y + e.clientHeight;
    _obj.style.height="300px";
    _obj.style.width="530px";
    _obj.style.zIndex = 5000;
    _obj.style.display = "block";
	var strUrl = "";	
    strUrl = "<%=contextPath %>/tdr/datatypein/ProdSelectPop.jsp?maxitem=10&<%= OvalTools.randomURL() %>&languagecode=cn";
    document.summaryfrm.location.href = strUrl;
}
function getPosition(e) {
        var left = 0;
        var top = 0;
        while (e.offsetParent) {
            left += e.offsetLeft + (e.curentStyle? (parseInt(e.curentStyle.borderLeftWidth).NaN0()):0);
            top += e.offsetTop + (e.curentStyle ? (parseInt(e.curentStyle.borderTopWidth)).NaN0() : 0);
            e = e.offsetParent;
        }
        left += e.offsetLeft + (e.curentStyle ? (parseInt(e.curentStyle.borderLeftWidth)).NaN0() : 0);
        top += e.offsetTop + (e.curentStyle ? (parseInt(e.curentStyle.borderTopWidth)).NaN0() : 0);
        return {x:left, y:top};
}
function closeItemSelect(evt)
{
	var _obj = document.getElementById("summaryfrm");
	if(isHidden == "block"){
		isHidden = "none";
	}else{
		_obj.style.display = "none";
	}
	evt = evt || window.event;
        var _target = evt.target || evt.srcElement;
        if (!_target.getAttribute("Author") && _target != inputObj && _target != targetObj) {
            getObjById("Calendar").style.display = "none";
            getObjById("CalendarFrm").style.display = "none";
        }
}

function hiddenFrm(){
	document.getElementById("summaryfrm").style.display = "none";
}

document.onclick=closeItemSelect;   

<%--[SCRIPT]    [SCRIPT]--%>
</script>

</head>
<body leftmargin="0" topmargin="0" marginwidth="0" marginheight="0">
<form name="cform" method="post" action="<%=contextPath %>/Dispatcher">
<input type="hidden" name="pagename" value="p_getchuanhuoinfosummary"> <input
	type="hidden" name="actionname"> <custom:hidden property="globalpccode"
	value="112" /> <%@ include file="/inc/PageLocation.inc"%>
<table width="100%" border="0" cellspacing="0">
	<tr>
		<td class="summary_top" colspan="2"></td>
	</tr>
	<%@ include file="/inc/SummarySearch.inc"%>
</table>
<table width="100%" cellspacing="0" cellpadding="0" border="0">
	<tr>
		<td>
		<table width="100%" border="1" cellpadding="0"
			bordercolorlight="#999999" bordercolordark="#FFFFFF" cellspacing="0"
			align="center">
			<tr class="deepblue-left">
				<td class="title_center" width="5%"><custom:checkbox
					property="checkall" styleClass="checkbox" onclick="page_checkall()" /></td>
			   <td class="title_center" width="10%"><a
					href="javascript:page_summary('orderby','flag')"><%= label.getLabelName("L_AdjustmentType") %></a><span
					class="red">*</span></td>
				<td class="title_center" width="35%"><a
					href="javascript:page_summary('orderby','prdn')"><%= label.getLabelName("L_Product") %></a><span
					class="red">*</span></td>
				<td class="title_center" width="15%"><a
					href="javascript:page_summary('orderby','qty')"><%= label.getLabelName("L_Qty") %></a><span
					class="red">*</span></td>
				<td class="title_center" width="20%"><a
					href="javascript:page_summary('orderby','startdate')"><%= label.getLabelName("L_StartDate") %></a><span
					class="red">*</span></td>
				<td class="title_center" width="20%"><a
					href="javascript:page_summary('orderby','enddate')"><%= label.getLabelName("L_EndDate") %></a></td>
			</tr>
			<span id="olddetail"> <%
		    Vector totalsummary=(Vector)pageContext.getAttribute("totalsummary");
		    if(totalsummary==null)
		    {
		    	totalsummary=new Vector();
		    }
		   
		    int i=1;
		    String strClassType="";
		    cat.debug("totalsummary is :"+totalsummary);
		%> <logic:iterate id="chuanhuoinfosummary"
				collection="<%= totalsummary %>">
				<%
        	HashMap HM = (HashMap)pageContext.getAttribute("chuanhuoinfosummary");
            Integer oColIndexLang=new Integer(i);
            if(i%2 == 0)
            {
              strClassType = "td-listrom";
            }else{                    
              strClassType = "none";
            }
            i++;
        %>

				<tr onMouseOver="this.className='tr-over'"
					onMouseOut="this.className='<%=JspHelper.filterNull(strClassType)%>'"
					class="<%=JspHelper.filterNull(strClassType)%>">
					<td class="title_center"><custom:checkbox
						property="zylchuanhuoinfoid" styleClass="checkbox"
						name="chuanhuoinfosummary" changedName="zylchuanhuoinfoids" /> <custom:hidden
						property="zylchuanhuoinfoid" name="chuanhuoinfosummary"
						colIndex="<%=oColIndexLang %>" /></td>
				    <td class="title_center">
						<custom:selectdic property="flag" colIndex="<%=oColIndexLang %>" name="chuanhuoinfosummary" dictType="ExcessType" valueCriteria="1,2" defaultValueCost="" defaultValue="-----" label="L_AdjustmentType" disabled="true"></custom:selectdic>
					</td>
					<td><custom:text property="prodcode" name="chuanhuoinfosummary"
						colIndex="<%=oColIndexLang %>" readonly="true" />
					&nbsp;&nbsp;&nbsp;&nbsp; <custom:text property="prdn"
						name="chuanhuoinfosummary" colIndex="<%=oColIndexLang %>"
						readonly="true" /> <custom:hidden property="productid"
						name="chuanhuoinfosummary" command="notnull" label="L_Product"
						colIndex="<%=oColIndexLang %>" /></td>
					<td><custom:text property="qty" name="chuanhuoinfosummary"
						command="notnull,positive" label="L_Qty"
						colIndex="<%=oColIndexLang %>" /></td>
					<td><input type="text" name="startdate<%=oColIndexLang %>"
						value="<%=HM.get("startdate") %>"
						onblur="if(startdate<%=oColIndexLang %>.value<0){alert('<%= message.getMessageDesc("VALUE_MUST_BE_DATE",label.getLabelName("L_BeginningDate",false)) %>');startdate<%=oColIndexLang %>.focus();}">
					<a
						onclick="c.show(this,'cform.startdate<%=oColIndexLang %>','<%=JspHelper.filterNull( session.getAttribute("dateformat") )%>')"><custom:button
						type="3" label="L_Asterisk" imgsrc="Time.gif" border="0" /></a></td>
					<td><input type="text" name="enddate<%=oColIndexLang %>" 
						value="<%=(HM.get("enddate")==null?"":HM.get("enddate")) %>"
						onblur="if(enddate<%=oColIndexLang %>.value<0){alert('<%= message.getMessageDesc("VALUE_MUST_BE_DATE",label.getLabelName("L_BeginningDate",false)) %>');enddate<%=oColIndexLang %>.focus();}" >
					<a
						onclick="c.show(this,'cform.enddate<%=oColIndexLang %>','<%=JspHelper.filterNull( session.getAttribute("dateformat") )%>')"><custom:button
						type="3" label="L_Asterisk" imgsrc="Time.gif" border="0" /></a>
				    </td>
				</tr>

			</logic:iterate> </span>
			<input type=hidden name=nums
				value="<%=JspHelper.filterNull(totalsummary.size())%>" />
			<input type=hidden name=numrows
				value="<%=LangNums*(JspHelper.filterNull(totalsummary.size())+1)%>" />

			<tr class="none">
				<td>&nbsp;</td>
				<td>
				<custom:selectdic property="flag"  name="newdata" dictType="ExcessType" valueCriteria="1,2" defaultValueCost="" defaultValue="-----"></custom:selectdic>
				</td>
				<td><custom:text property="prodcode" name="newdata" /> <a
					onclick="javascript:javascript:frm_select(this);"><custom:button
					type="3" label="L_Asterisk" imgsrc="flash.gif" border="0" /></a> <custom:text
					property="prodname" name="newdata" /> <custom:hidden
					property="productid" name="newdata" 
					label="L_Product" />
				<td><custom:text property="qty" name="newdata" label="L_Qty" dataType="integer" />
				</td>
				<td><input type="text" name="startdate" value=""
					onblur="if(startdate.value<0){alert('<%= message.getMessageDesc("VALUE_MUST_BE_DATE",label.getLabelName("L_BeginningDate",false)) %>');startdate.focus();}">
				<a
					onclick="c.show(this,'cform.startdate','<%=JspHelper.filterNull( session.getAttribute("dateformat") )%>')"><custom:button
					type="3" label="L_Asterisk" imgsrc="Time.gif" border="0" /></a></td>
				<td><input type="text" name="enddate" value=" "
					onblur="if(enddate.value<0){alert('<%= message.getMessageDesc("VALUE_MUST_BE_DATE",label.getLabelName("L_BeginningDate",false)) %>');enddate.focus();}">
				<a
					onclick="c.show(this,'cform.enddate','<%=JspHelper.filterNull( session.getAttribute("dateformat") )%>')"><custom:button
					type="3" label="L_Asterisk" imgsrc="Time.gif" border="0" /></a></td>

			</tr>
			<%@ include file="/inc/SummaryAction.inc"%>
		</table>

		<table width="100%" border="0" cellspacing="0" cellpadding="0">
			<tr>
				<td class="summary_top"></td>
			</tr>
			<tr>
				<td class="td_center"><a onclick="page_add()"><custom:button
					type="1" label="L_Add" imgsrc="add.gif" border="0" style="width:60" /></a>
				<a onclick="page_save();"><custom:button type="1" label="L_Save"
					imgsrc="cancel.gif" border="0" style="width:60" /></a> <a
					onclick="page_delete()"><custom:button type="1" label="L_Delete"
					imgsrc="delete.gif" border="0" style="width:60" /></a></td>
			</tr>
		</table>
		</td>
	</tr>
</table>
</form>
<script type="text/javascript">
function checkalltext(){
    var retVal=true;
	for(var i =1;i<=<%=JspHelper.filterNull(totalsummary.size())%>;i++){
		var startdate = eval("cform.startdate"+i);
		var enddate = eval("cform.enddate"+i);
		var numqty = eval("cform.qty"+i);
		var flag =  eval("cform.flag"+i);

       /*if(flag.value=="" || flag.value==null){
			alert("类型不能为空！");
			flag.focus();
			retVal=false;
			return;
		}*/
		if(numqty.value=="" || numqty.value==null){
			alert("数量不能为空！");
			numqty.focus();
			retVal=false;
			return;
		}
		  
		if (isNaN(Number(numqty.value))){
			alert("请输入正确的数值！");
			numqty.focus();
			retVal=false;
			return;
		}
	   
	  if(!isDate(startdate.value,"yyyy-MM-dd")){
			alert("日期格式不正确！");
			startdate.focus();
			retVal=false;
			return;
		  }
	  if(!isDate(enddate.value,"yyyy-MM-dd")){
			alert("日期格式不正确！");
			enddate.focus();
			retVal=false;
			return;
		  }
	  if(startdate.value=="" || startdate.value==null){
			alert("开始时间不能为空");
			startdate.focus();
			retVal=false;
			return;
		  }
	}
	return retVal;
 }


</script>
</body>
</html>


